//
//  ViewController.m
//  小说
//
//  Created by WZH on 2018/5/23.
//  Copyright © 2018年 WZH. All rights reserved.
//

#import "ViewController.h"


@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    [self luoji];
}


// 开始相互独立逻辑
// 循环
// 请求
// 归档url数据
// 下载
// 观看网络视频
// 观看本地视频
// 查看下载进度
// 删除视频
// 进入密码
- (void)luoji{
    //    UIWebView *web = [[UIWebView alloc] initWithFrame:self.view.bounds];
    //    [self.view addSubview:web];
    //    [web loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.fuli14.me/forum-40-47.html"]]];
    //    http://www.fuli14.me:80/p/fuli.php?fuli=/20180209/GBtVkTag/f%3A%27%2Fckplayer%2Fm3u8.swf%27%2C
    //    http://www.fuli14.me/p/fuli.php?fuli=/20180209/GBtVkTag/index.m3u8
    //    http://www.fuli14.me/thread-26869-1-1.html
    //    http://www.fuli14.me/thread-26870-1-1.html
    //    http://www.fuli14.me/p/fuli.php?fuli=/20180506/nNd9itFr/index.m3u8
    //    数据分析对比
    //    http://www.fuli14.me/thread- 开头
    //    -1-1.html                    结尾
    //    中间大于                       15812
    //    获取url拦截                   index.m3u8 结尾
    //    index.m3u8分割数组取 firstObject
    //    src="分割取lastObject
    //    形成列表bn
    
        [HJTNetTool get:@"http://www.fuli14.me/thread-15812-1-1.html" progress:nil success:^(id  _Nonnull responseObject) {
            [MemberModel addTitle:[self getTitle:responseObject] url:[self getUrl:responseObject] id:@"15812"];
            NSLog(@"%@",NSHomeDirectory());
            NSLog(@"%lu",(unsigned long)[MemberModel unarchive].infoArray.count);
        } failure:^(NSString * _Nonnull errorLD) {
//            <br />\n<iframe
//            </div>
        }];
}

- (NSString *)getTitle:(NSString *)string{
    NSString *string1 = [string componentsSeparatedByString:@"http://www.fuli14.me/thread-"].lastObject;
    NSString *string2 = [string1 componentsSeparatedByString:@"-1-1.html"].firstObject;
    return [NSString stringWithFormat:@"http://www.fuli14.me/thread-%@-1-1.html",string2];
}

- (NSString *)getUrl:(NSString *)string{
    NSString *string1 = [string componentsSeparatedByString:@"<title>"].lastObject;
    NSString *string2 = [string1 componentsSeparatedByString:@"</title>"].firstObject;
    return [string2 componentsSeparatedByString:@"-"].firstObject;
}

@end
